package com.yjc.rabbitMQ.five;

import com.rabbitmq.client.Channel;
import com.yjc.rabbitMQ.utils.RabbitMQUtils;

import java.util.Scanner;

/**
 * @author shkstart
 * @create 2022-07-31 15:25
 */
public class EmitLog {

    private static final String EXCHANG_NAME = "logs";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();
        channel.exchangeDeclare(EXCHANG_NAME, "fanout");
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String message = sc.next();
            channel.basicPublish(EXCHANG_NAME, "", null, message.getBytes("UTF-8"));
            System.out.println("发送消息 " + message + " 中...");
        }

    }
}
